<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/jquery-1.8.3.js"></script>
    <script>
        function check() {
            var x = $("[name='name']").val().length;
            if (x>10){
                alert("太长了");
                return false;
            }
            if ($("[name='age']").val()>100){
                alert("岁数比较大")
                return false;
            }
        }
    </script>
</head>
<body>
    <form action="/addTeacher.do" method="post">
        <input type="text" name="name" placeholder="请输入姓名">
        <input type="text" name="age" placeholder="请输入年龄">
        <input type="submit" onclick="return check()" value="提交">
    </form>
</body>
</html>